//
//  TabViewController.m
//  demo01
//
//  Created by 小胖子 on 2020/7/16.
//  Copyright © 2020 小胖子. All rights reserved.
//

#import "TabViewController.h"
#import "ToolClass.h"
#import "BaseNavgationController.h"
#import "HomeViewController.h"
#import "ActivityViewController.h"

@interface TabViewController ()

@end

@implementation TabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.tabBar setTranslucent:NO];
    
    HomeViewController *homeVc = [[HomeViewController alloc] init];
    [self addChildVC:homeVc title:@"主页" image:@"home_no" selectImage:@"home_yes"];
    
    ActivityViewController *actitityVc = [[ActivityViewController alloc] init];
    [self addChildVC:actitityVc title:@"活动" image:@"activity_no" selectImage:@"activity_yes"];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void)addChildVC: (UIViewController *) childVc title:(NSString *)title image:(NSString *) image selectImage:(NSString *) selectImage {
    childVc.tabBarItem.title = title;
    
    childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [ToolClass colorFromHexRGB:@"C4A4A3"];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    selectAttrs[NSForegroundColorAttributeName]=RGB(255, 110, 110, 1);
    selectAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    
    [childVc.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [childVc.tabBarItem setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
     // UINavigationController *navigation basena
    UINavigationController *navigation = [[BaseNavgationController alloc] initWithRootViewController:childVc];
    [self addChildViewController:navigation];
}

@end
